/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.edu.agh.io.gpstracker.model;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author wkedzior
 */
@Entity
@Table(name = "places")
@NamedQueries({
    @NamedQuery(name = "Places.findAll", query = "SELECT p FROM Places p"),
    @NamedQuery(name = "Places.findById", query = "SELECT p FROM Places p WHERE p.id = :id"),
    @NamedQuery(name = "Places.findByType", query = "SELECT p FROM Places p WHERE p.type = :type"),
    @NamedQuery(name = "Places.findByName", query = "SELECT p FROM Places p WHERE p.name = :name"),
    @NamedQuery(name = "Places.findByDescription", query = "SELECT p FROM Places p WHERE p.description = :description")})
public class Places implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Column(name = "type")
    private Short type;
    @Column(name = "name")
    private String name;
    @Column(name = "description")
    private String description;
    @JoinColumn(name = "node_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Node node;
    @OneToMany(mappedBy = "places")
    private List<Tracksequence> tracksequenceList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "places")
    private List<Userplaces> userplacesList;

    public Places() {
    }

    public Places(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Short getType() {
        return type;
    }

    public void setType(Short type) {
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Node getNode() {
        return node;
    }

    public void setNode(Node node) {
        this.node = node;
    }

    public List<Tracksequence> getTracksequenceList() {
        return tracksequenceList;
    }

    public void setTracksequenceList(List<Tracksequence> tracksequenceList) {
        this.tracksequenceList = tracksequenceList;
    }

    public List<Userplaces> getUserplacesList() {
        return userplacesList;
    }

    public void setUserplacesList(List<Userplaces> userplacesList) {
        this.userplacesList = userplacesList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Places)) {
            return false;
        }
        Places other = (Places) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pl.edu.agh.io.gpstracker.model.Places[id=" + id + "]";
    }

}
